﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MSBDATAModel;
public partial class Admin_QLTheThanhToan : System.Web.UI.Page
{
    MSBDATAEntities entities = new MSBDATAEntities();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin"] != null)
        {
            if (!IsPostBack)
            {
                try
                {
                    this.GridViewDSThe.AutoGenerateColumns = false;


                    // create column
                    BoundField field = new BoundField();
                    field.DataField = "ChuThe";
                    field.HeaderText = "Chủ thẻ";
                    GridViewDSThe.Columns.Add(field);

                    field = new BoundField();
                    field.DataField = "TenChuThe";
                    field.HeaderText = "Tên chủ thẻ";
                    GridViewDSThe.Columns.Add(field);

                    field = new BoundField();
                    field.DataField = "SoThe";
                    field.HeaderText = "Số thẻ";
                    GridViewDSThe.Columns.Add(field);

                    field = new BoundField();
                    field.DataField = "LoaiThe";
                    field.HeaderText = "Loại thẻ";
                    GridViewDSThe.Columns.Add(field);

                    field = new BoundField();
                    field.DataField = "HanSuDung";
                    field.HeaderText = "Hạn sử dụng";
                    GridViewDSThe.Columns.Add(field);

                    field = new BoundField();
                    field.DataField = "TaiKhoanNH";
                    field.HeaderText = "Số tài khoản ngân hàng";
                    GridViewDSThe.Columns.Add(field);

                    field = new BoundField();
                    field.DataField = "SoTien";
                    field.HeaderText = "Số tiền";
                    GridViewDSThe.Columns.Add(field);

                    field = new BoundField();
                    field.DataField = "LoaiTien";
                    field.HeaderText = "Đơn vị tiền tệ";
                    GridViewDSThe.Columns.Add(field);


                    this.GridViewDSThe.DataSource = from t in entities.THE_THANH_TOAN
                                                    where t.C_LOAI_THE.MaLoaiThe == 2
                                                    select new
                                                    {
                                                        ChuThe = t.TAI_KHOAN_NGAN_HANG.TAI_KHOAN_WEB.TenDangNhap,
                                                        TenChuThe = t.TAI_KHOAN_NGAN_HANG.TAI_KHOAN_WEB.Ten,
                                                        SoThe = t.SoThe,
                                                        LoaiThe = t.C_LOAI_THE.TenLoaiThe,
                                                        HanSuDung = t.HanSuDung,
                                                        TaiKhoanNH = t.TAI_KHOAN_NGAN_HANG.SoTaiKhoan,
                                                        SoTien = t.TAI_KHOAN_NGAN_HANG.SoTien,
                                                        LoaiTien = t.TAI_KHOAN_NGAN_HANG.C_TIEN_TE.MaTienTe
                                                    };
                    this.GridViewDSThe.DataBind();
                }
                catch (Exception)
                {
                    Response.Redirect("NotLogin.aspx");
                }
            }
        }
        else
            Response.Redirect("NotLogin.aspx");
    }
}